import axios from '../utils/http'

const MenuStore = {
    namespaced:true,
    state:()=>({
        menuList:[]

        //组件使用数据
    }),
    mutations:{
        MenuListMutation(state,list){
            //修改state数据
            state.menuList = list
        }
    },
    actions:{
        MenuListAction(context){
            //获取后台数据
            axios.get('/api/menulist?istree=1').then(res=>{
                if(res.code ===403){
                    localStorage.removeItem('logindata')
                    window.location.href ='/login'
                }else{
                    if(res.code === 200){
                        context.commit('MenuListMutation',res.list)
                    }
                }
                console.log(res);
            })
        }
    }
}
export default MenuStore